#include "virtualdevice.h"
#include "vd.h"


VirtualDevice::VirtualDevice(const std::string &path)
    : DeviceInterface{path}
    , m_isOpen{false}
{
    m_data.push(VD_XXKJ_DSP48::name());
    m_data.push(VD_XXKJ_DSP48::info());
    m_data.push(VD_XXKJ_DSP48::system());
    m_data.push(VD_XXKJ_DSP48::scn());
}

VirtualDevice::~VirtualDevice()
{

}

bool VirtualDevice::open()
{
    m_isOpen = true;
    return true;
}

void VirtualDevice::close()
{
    m_isOpen = false;
}

bool VirtualDevice::isOpen() const
{
    return m_isOpen;
}

void VirtualDevice::write([[maybe_unused]] const std::vector<uint8_t> &data, [[maybe_unused]] const uint16_t &timeout)
{
    if (!m_data.empty()) {
        recv(m_data.front());
        m_data.pop();
    }
}

std::string VirtualDevice::getDescription() const
{
    return "This is a virtual device.";
}
